<?php
class tbl_billing_log extends AppModel
{
    public $useTable = 'tbl_billing_log';
    public $useDbConfig = 'log_db';
    public $order = array('reg_date' => 'DESC');

    public function get_billing_list($_id)
    {
        $params = array(
            'conditions' => array(
                'a2x_id' => $_id,
            ),
            'fields' => array(
                'a2x_id', 'order_id', 'cash', 'reg_date'
            ),
        );
        $data = $this->find('all', $params);

        return $data;
    }

    public function get_today_billing($_date)
    {
        $params = array(
            'fields' => array('a2x_id', 'reg_date'),
            'conditions' => array(
                'DATE(reg_date)' => $_date
            ),
            'group' => 'a2x_id'
        );
        $data = $this->find('count', $params);

        if( empty($data))
            $data = '-';
        return $data;
    }

    public function get_today_billing_list($_date)
    {
        $params = array(
            'fields' => array('a2x_id', 'order_id', 'cash', 'reg_date'),
            'conditions' => array(
                'DATE(reg_date)' => $_date
            ),
        );
        $data = $this->find('all', $params);

        return $data;
    }

    public function get_today_sales($_date)
    {
        $params = array(
            'fields' => array('reg_date', 'cash'),
            'conditions' => array(
                'DATE(reg_date)' => $_date
            ),
        );
        $data = $this->find('all', $params);

        return $data;
    }


}